﻿<phone:PhoneApplicationPage 
    x:Class="nyxwin.Main.View.SubViews.Discussion"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:lc="clr-namespace:nyxwin.Main.Controls"
    xmlns:comconv="clr-namespace:nyxwin.Common.Silverlight.Converters;assembly=nyxwin.Common"
    xmlns:comctrls="clr-namespace:nyxwin.Common.Silverlight.Controls;assembly=nyxwin.Common"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.Resources>
        <Style TargetType="ListBoxItem" x:Key="ListBoxStretchStyle">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,20" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <comconv:BoolToVisibilityConverter x:Key="boolToVisibilityConverter" />
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{Binding Path=Title}" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid Grid.Row="1" Margin="12,0,12,0">
            <ScrollViewer>
                <StackPanel>
                    <ListBox
                        ItemsSource="{Binding Path=Posts}"
                        ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                        ScrollViewer.VerticalScrollBarVisibility="Disabled"
                        HorizontalContentAlignment="Stretch" 
                        ItemContainerStyle="{StaticResource ListBoxStretchStyle}"
                        >
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="0,0,12,10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="1*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition />
                                    </Grid.RowDefinitions>

                                    <StackPanel Grid.RowSpan="2" Orientation="Vertical" Margin="6,0,0,5">
                                        <lc:NyxIcon Grid.RowSpan="2" Uri="{Binding NickImageUrl}" VerticalAlignment="Top" HorizontalAlignment="Center" Tap="NyxIcon_Tap">
                                            <toolkit:ContextMenuService.ContextMenu>
                                                <toolkit:ContextMenu>
                                                    <toolkit:MenuItem Header="{Binding Path=Localization.Resource.OpenInBrowser}" Command="{Binding Path=BrowserCommand}" />
                                                </toolkit:ContextMenu>
                                            </toolkit:ContextMenuService.ContextMenu>
                                        </lc:NyxIcon>
                                        <Ellipse Width="10" Height="10" Fill="Red" Stroke="Red" Visibility="{Binding Path=MarkedUnread, Converter={StaticResource boolToVisibilityConverter}}" />
                                    </StackPanel>

                                    <Grid Grid.Column="1">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="1*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>

                                        <TextBlock Text="{Binding Nick}" Style="{StaticResource PhoneTextAccentStyle}" FontWeight="Bold" FontSize="{StaticResource PhoneFontSizeMediumLarge}" VerticalAlignment="Center" Margin="18,0,12,0" />

                                        <TextBlock Grid.Column="1" Text="{Binding DisplayTime}" Style="{StaticResource PhoneTextSubtleStyle}" FontSize="{StaticResource PhoneFontSizeSmall}" Margin="12,0,0,0" VerticalAlignment="Center" FontStyle="Italic" />
                                    </Grid>

                                    <comctrls:HtmlContentTextBox HtmlContent="{Binding Content}" Grid.Row="1" Grid.Column="1" Margin="0,5" HorizontalAlignment="Left" VerticalAlignment="Top" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" />
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
            </ScrollViewer>
        </Grid>
    </Grid>
 
    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>
